package com.yc.cloud.common.basic.utils;

import java.security.SecureRandom;

public class AppIdGenerator {
    private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    private static final SecureRandom random = new SecureRandom();

    public static String generateAppId(boolean lowerCase) {
        StringBuilder sb = new StringBuilder(6);
        for (int i = 0; i < 6; i++) {
            sb.append(CHARACTERS.charAt(random.nextInt(CHARACTERS.length())));
        }
        if (lowerCase) {
            return sb.toString().toLowerCase();
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        String appId = generateAppId(true);
        System.out.println("Generated App ID: " + appId);
    }
}

